package com.nyp.lotteryf.entity;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

public class User {
	
	@NotNull
	@Pattern(regexp="^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$", message="Érvényes e-mail címet adjál meg!")
	private String mailAddress;
	
	@NotNull
	private String name;

	public String getMailAddress() {
		return mailAddress;
	}

	public void setMailAddress(String mailAddress) {
		this.mailAddress = mailAddress;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (mailAddress == null) {
			if (other.mailAddress != null)
				return false;
		} else if (!mailAddress.equals(other.mailAddress))
			return false;
		return true;
	}
	
	@Override
	public User clone(){
		User ret = new User();
		ret.setMailAddress(mailAddress);
		ret.setName(name);
		return ret;
	}
	
}
